<!-- 集体备课卡片  -->
<template>
  <div class="teachCard" @click="toDetails">
    <div class="cardBanner">
      <img
        class="cardImg"
        :src="$getImageUrl(cardData.originImg)"
        alt=""
        srcset=""
      />
      <!-- <div class="cardTag">我参与的</div> -->
    </div>
    <div class="cardInfo">
      <div class="cardTitle oneHidden">
        {{  cardData.name }}
      </div>
      <div class="cardSecondary oneHidden">
        {{ cardData.description }}
      </div>
      <div class="initiator">发起人：{{ cardData.promoter || '无' }}</div>
      <div class="participant">{{ cardData.joins }}人参与</div>
      <div class="cardOther">
        <div class="lecturer">
          <div class="statusTag" :class="{ statusIng: cardData.status === 'START', statusEnd: cardData.status === 'END' }">
            {{ cardData.status ? statusArr[cardData.status].txt : '新发布'}}
          </div>
          <!-- <div v-if="cardData.status !== 'NO_START'" class="session">1场</div> -->
        </div>
        <div class="booking">
          <!-- <span>下一场：</span>尚未设置 -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TeachCard',
  props: {
    cardData: {
      type: Object,
      default: () => {
        return {
          originImg: '',
          status: 'NO_START'
        }
      },
    },
  },
  data() {
    return {
      statusArr: {
        NO_START: {
          txt: '新发布',
        },
        START: {
          txt: '进行中',
        },
        END: {
          txt: '已结束'
        },
      }
    };
  },
  methods: {
    toDetails() {
      const url = this.$router.resolve({
        path: '/teachDetails',
        query: {
          id: this.cardData.objectId
        }
      }).href;
      window.open(url, '_blank');
    },
  },
};
</script>

<style scoped lang="scss">
.teachCard {
  width: 326px;
  height: 375px;
  border-radius: 8px;
  box-shadow: $box-shadow;
  background: #fff;
  &:hover {
    box-shadow: $box-shadow-hover;
  }

  .cardBanner {
    width: 100%;
    height: 196px;
    position: relative;
    background: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    border-radius: 8px 8px 0 0;
    .cardImg {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .cardTag {
      color: #fff;
      padding: 4px 6px;
      border-radius: 2px 0px 0px 0px;
      background: rgba(0, 0, 0, 0.5);
      position: absolute;
      top: 12px;
      right: 12px;
      font-size: 12px;
      font-weight: 600;
      line-height: 16.8px;
    }
  }
  .cardInfo {
    padding: 12px 16px 0;
    .cardTitle {
      width: 100%;
      height: 21px;
      font-size: 14px;
      font-weight: 600;
      line-height: 21px;
      color: $text-title-color;
    }
    .cardSecondary {
      font-weight: 400;
      line-height: 18px;
      font-size: 12px;
      margin-top: 8px;
      color: $text-color;
    }
    .initiator,
    .participant {
      font-size: 12px;
      line-height: 18px;
      color: $text-color-secondary;
      font-weight: 400;
    }
    .initiator {
      margin-top: 16px;
    }
    .participant {
      margin-top: 4px;
    }
    .cardOther {
      display: flex;
      align-items: center;
      margin-top: 24px;
      justify-content: space-between;
      height: 24px;
      .lecturer {
        display: flex;
        .statusTag {
          padding: 4px 6px;
          box-sizing: border-box;
          font-size: 12px;
          font-weight: 600;
          line-height: 16px;
          background: linear-gradient(270deg, #62E768 0%, #24D82C 100%);
          color: #fff;
        }
        .statusIng {
          background: linear-gradient(270deg, #5EA3F5 0%, #368CF2 100%);
        }
        .statusEnd {
          background: #8C8C8C;
        }
        .session {
          padding: 0 6px;
          height: 24px;
          line-height: 24px;
          font-size: 12px;
          font-weight: 400;
          color: #8C8C8C;
          background: #F0F0F0;
        }
      }
      .booking {
        color: $text-color-secondary;
        font-size: 12px;
        font-weight: 400;
        line-height: 18px;
        span {
          color: $text-color;
        }
      }
    }
  }
}
</style>
